import Vue from 'vue';
import Router from 'vue-router';

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router);

/* Layout */
import Layout from '@/views/layout/Layout';

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/

export const constantRouterMap = [//无需权限控制的。
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [{
      path: '/redirect/:path*',
      component: () => import('@/views/redirect/index')
    }]
  },
  
  //未用层包裹
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true,
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    name: '错误页面',
    hidden: true
  },
  
];

export default new Router({
  // mode: 'history', //后端支持可开  
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRouterMap, //   createMyRouter(): constantRouterMap
});


export const asyncRouterMap = [
  {//我的桌面,无权限，每个账号都可用
    path: '',
    component: Layout,
    redirect: 'mydesktop',
    name: '首页',
    meta: {
      title: '我的桌面',
      icon: 'dashboard',      
    },
    leaf: true,
    children: [{
      path: '/mydesktop',
      component: () => import('@/views/mydesktop/index'),
      name: '我的桌面',
      meta: {
        title: '我的桌面',
        icon: 'dashboard',
        noCache: true
      },
    }]
  },

  //------------------------业务相关，都与权限关联----------------------------------------
  //-----------------------------不用包裹 -----------------------------------------------
  
  {//商品相关
    path: '/addproduct',
    component: () => import('@/views/product/data/add/index'),
    name: 'addproduct',
    hidden: true,
    noCache: true,
    right:'',
  },
  {
    path: '/editproduct',
    component: () => import('@/views/product/data/edit/index'),
    name: 'editproduct',
    hidden: true,
    noCache: true,
    right:'',
  },
  {
    path: '/addproduct/market',
    component: () => import('@/views/product/data/add/index_market'),//src\views\product\data\add\index_market.vue
    name: 'addproductmarket',
    hidden: true,
    noCache: true,
    right:'',
  },
  {
    path: '/editproduct/market',
    component: () => import('@/views/product/data/edit/index_market'),//src\views\product\data\edit\index_market.vue
    name: 'editproductmarket',
    hidden: true,
    noCache: true,
    right:'',
  },
  {
    path: '/previewproduct',
    component: () => import('@/views/product/data/preview/index'),//src\views\product\data\preview\index.vue
    name: 'previewproduct',
    hidden: true,
    noCache: true,
    right:'',
  },
  //--------------------------------------用包裹 --------------------------------------------------
  {//赠品管理
    path: '',
    component: Layout,
    name: '赠品管理',      
    iconCls:'el-icon-s-shop',
    meta: {
      title: '赠品管理',
      icon: 'dashbord',
    },
    children: [{
        path: '/product-gift/list',
        component: () => import('@/views/product/data/list/index'),
        name: '赠品列表',
        meta: {
          title: '赠品列表',
          icon: 'dashboard',
          noCache: true,
          right: 'ProductData_List',
        }
      },
      {
        path: '/product-setmeal/list',
        component: () => import('@/views/product/data/list/index'),
        name: '赠品套餐',
        meta: {
          title: '赠品套餐',
          icon: 'dashboard',
          noCache: true,
          right: 'ProductData_List',
        }
      },
      {
        path: '/product/kind',
        component: () => import('@/views/product/category/index'),//src\views\product\category\index.vue
        name: '赠品类别设置',
        meta: {
          title: '商品类别设置',
          icon: 'dashboard',
          noCache: true,
          right: 'ProductData_List',
        },
      },
      {
        path: '/product-giftcity/list',
        component: () => import('@/views/product/data/list/index'),
        name: '赠品商城设置',
        meta: {
          title: '赠品商城设置',
          icon: 'dashboard',
          noCache: true,
          right: 'ProductData_List',
        }
      },
    ]
  },
  {//超市商品
    path: '',
    component: Layout,
    name: '超市商品',
    meta: {
      title: '超市商品',
      icon: 'dashbord'
    },
    children: [{
        path: '/product-market/list',
        component: () => import('@/views/product/data/list/index_market'),//src\views\product\data\list\index_market.vue
        name: '商品列表',
        meta: {
          title: '商品列表',
          icon: 'dashboard',
          noCache: true,
          right: 'ProductData2_List',
        }
      },
      {
        path: '/product-active/list',
        component: () => import('@/views/product/data/list/index'),
        name: '商品活动',
        meta: {
          title: '商品活动',
          icon: 'dashboard',
          noCache: true,
          right: 'ProductData2_List',
        }
      },
      {
        path: '/product-market/kind',
        component: () => import('@/views/product/category/index_market'),//src\views\product\category\index_market.vue
        name: '商品类别设置',
        meta: {
          title: '商品类别设置',
          icon: 'dashboard',
          noCache: true,
          right: 'ProductData2_List',
        },
      },
      {
        path: '/product-market/set',
        component: () => import('@/views/product/data/list/index'),
        name: '超市商城设置',
        meta: {
          title: '超市商城设置',
          icon: 'dashboard',
          noCache: true,
          right: 'ProductData2_List',
        }
      },
    ]
  },
  {//订单管理
    path: '',
    component: Layout,
    name: '订单管理',
    iconCls:'el-icon-s-order',
    meta: {
      title: '订单管理',
      icon: 'dashbord'
    },
    children: [{
        path: '/order/list',
        component: () => import('@/views/product/data/list/index'),
        name: '订单列表',
        meta: {
          title: '订单列表',
          icon: 'dashboard',
          noCache: true,
          right: 'OrderData_List',
        }
      },
      {
        path: '/order-gift/list',
        component: () => import('@/views/product/data/list/index'),
        name: '赠品订单列表',
        meta: {
          title: '赠品订单列表',
          icon: 'dashboard',
          noCache: true,
          right: 'OrderData_List',
        }
      },
      {
        path: '/order-market/list',
        component: () => import('@/views/product/data/list/index'),
        name: '超市订单列表',
        meta: {
          title: '超市订单列表',
          icon: 'dashboard',
          noCache: true,
          right: 'OrderData_List',
        }
      },
    ]
  },
  {//售后管理
    path: '',
    component: Layout,
    name: '售后管理',
    //hidden: true,
    meta: {
      title: '售后管理',
      icon: 'dashbord'
    },
    children: [{
        path: '/after-sale/list',
        component: () => import('@/views/product/data/list/index'),
        name: '售后列表',
        meta: {
          title: '售后列表',
          icon: 'dashboard',
          noCache: true,
          right: 'OrderData2_List',
        },
      },
      {
        path: '/after-sale/evaluate',
        component: () => import('@/views/product/data/list/index'),
        name: '评价管理',
        meta: {
          title: '评价管理',
          icon: 'dashboard',
          noCache: true,
          right: 'OrderData2_List',
        },
      },
      {
        path: '/after-sale/feedback',
        component: () => import('@/views/product/data/list/index'),
        name: '留言反馈',
        meta: {
          title: '留言反馈',
          icon: 'dashboard',
          noCache: true,
          right: 'OrderData2_List',
        },
      },
    ]
  },
  {//财务管理
    path: '',
    component: Layout,
    name: '财务管理',
    iconCls:'el-icon-s-data',
    meta: {
      title: '财务管理',
      icon: 'dashbord'
    },
    children: [{
        path: '/finance-cost/list',
        component: () => import('@/views/product/data/list/index'),
        name: '费用明细',
        meta: {
          title: '费用明细',
          icon: 'dashboard',
          noCache: true,
          right: 'OrderPay_List',
        }
      },
      {
        path: '/finance-order/list',
        component: () => import('@/views/product/data/list/index'),
        name: '订单明细',
        meta: {
          title: '订单明细',
          icon: 'dashboard',
          noCache: true,
          right: 'OrderPay_List',
        }
      },
      {
        path: '/finance-impulsevalue/list',
        component: () => import('@/views/product/data/list/index'),
        name: '冲值明细',
        meta: {
          title: '冲值明细',
          icon: 'dashboard',
          noCache: true,
          right: 'OrderPay_List',
        }
      },
      {
        path: '/finance-cashwithdrawal/list',
        component: () => import('@/views/product/data/list/index'),
        name: '提现明细',
        meta: {
          title: '提现明细',
          icon: 'dashboard',
          noCache: true,
          right: 'OrderPay_List',
        }
      },
      {
        path: '/finance-item/list',
        component: () => import('@/views/product/data/list/index'),
        name: '项目分配明细',
        meta: {
          title: '项目分配明细',
          icon: 'dashboard',
          noCache: true,
          right: 'OrderPay5_List',
        }
      },
      {
        path: '/finance-item/list',
        component: () => import('@/views/product/data/list/index'),
        name: '峰会费用明细',
        meta: {
          title: '峰会费用明细',
          icon: 'dashboard',
          noCache: true,
          right: 'OrderPay4_List',
        }
      },
      {
        path: '/finance-merchantcommission/list',
        component: () => import('@/views/product/data/list/index'),
        name: '商家佣金收益',
        meta: {
          title: '商家佣金收益',
          icon: 'dashboard',
          noCache: true,
          right: 'OrderPay2_List',
        }
      },
      {
        path: '/finance-ownerconsumption/list',
        component: () => import('@/views/product/data/list/index'),
        name: '业主消费收益',
        meta: {
          title: '业主消费收益',
          icon: 'dashboard',
          noCache: true,
          right: 'OrderPay3_List',
        }
      },
      {
        path: '/finance-ownerrecommend/list',
        component: () => import('@/views/product/data/list/index'),
        name: '业主推介收益',
        meta: {
          title: '业主推介收益',
          icon: 'dashboard',
          noCache: true,
          right: 'OrderPay3_List',
        }
      },
      {
        path: '/finance-ownerrecommend/list',
        component: () => import('@/views/product/data/list/index'),
        name: '峰会提成收益',
        meta: {
          title: '峰会提成收益',
          icon: 'dashboard',
          noCache: true,
          right: 'OrderPay4_List',
        }
      },
    ]
  },
  {//消息管理
    path: '',
    component: Layout,
    name: '消息管理',
    iconCls:'el-icon-s-comment',
    meta: {
      title: '消息管理',
      icon: 'dashbord'
    },
    children: [{
        path: '/message/list',
        component: () => import('@/views/product/data/list/index'),
        name: '消息列表',
        meta: {
          title: '消息列表',
          icon: 'dashboard',
          noCache: true,
          right: 'MessageData_List',
        }
      },
      {
        path: '/message-system/list',
        component: () => import('@/views/product/data/list/index'),
        name: '系统消息',
        meta: {
          title: '系统消息',
          icon: 'dashboard',
          noCache: true,
          right: 'MessageData_List',
        }
      },
      {
        path: '/message-owner/list',
        component: () => import('@/views/product/data/list/index'),
        name: '业务消息',
        meta: {
          title: '业务消息',
          icon: 'dashboard',
          noCache: true,
          right: 'MessageData_List',
        }
      },
    ]
  },
  {//机构管理
    path: '',
    component: Layout,
    name: '机构管理',
    meta: {
      title: '机构管理',
      icon: 'dashbord'
    },
    children: [
      {
        path: '/mechanism-department/list',
        component: () => import('@/views/product/data/list/index'),
        name: '内部部门',
        meta: {
          title: '内部部门',
          icon: 'dashboard',
          noCache: true,
          right:'BranchData_List',
        }
      },
      {
        path: '/mechanism-partner/list',
        component: () => import('@/views/product/data/list/index'),
        name: '合伙人机构',
        meta: {
          title: '合伙人机构',
          icon: 'dashboard',
          noCache: true,
          right:'BranchData_List',
        },
      },
    ]
  },
  {//员工管理
    path: '',
    component: Layout,
    name: '员工管理',
    meta: {
      title: '员工管理',
      icon: 'dashbord'
    },
    children: [
      {
        path: '/mechanism-departmenustaff/list',
        component: () => import('@/views/product/data/list/index'),
        name: '内部员工',
        meta: {
          title: '内部员工',
          icon: 'dashboard',
          noCache: true,
          right:'BranchStaff_List',
        }
      },
      {
        path: '/mechanism-staff/list',
        component: () => import('@/views/product/data/list/index'),
        name: '合伙人员工',
        meta: {
          title: '合伙人员工',
          icon: 'dashboard',
          noCache: true,
          right:'BranchStaff_List',
        }
      },
    ]
  },
  {//项目管理
    path: '',
    component: Layout,
    name: '项目管理',
    meta: {
      title: '项目管理',
      icon: 'dashbord'
    },
    children: [
      {
        path: '/project/list',
        component: () => import('@/views/product/data/list/index'),
        name: '项目列表',
        meta: {
          title: '项目列表',
          icon: 'dashboard',
          noCache: true,
          right:'ProjectData_List',
        },
      },
      {
        path: '/project-approval/list',
        component: () => import('@/views/product/data/list/index'),
        name: '项目审批',
        meta: {
          title: '项目审批',
          icon: 'dashboard',
          noCache: true,
          right:'ProjectData_List',
        }
      },
      {
        path: '/project-distribution/list',
        component: () => import('@/views/product/data/list/index'),
        name: '分配方案',
        meta: {
          title: '分配方案',
          icon: 'dashboard',
          noCache: true,
          right:'ProjectData_List',
        }
      },
    ]
  },
  {//业主管理
    path: '',
    component: Layout,
    name: '业主管理',
    iconCls:'el-icon-user-solid',
    meta: {
      title: '业主管理',
      icon: 'dashbord'
    },
    children: [
      {
        path: '/owner/list',
        component: () => import('@/views/product/data/list/index'),
        name: '业主列表',
        meta: {
          title: '业主列表',
          icon: 'dashboard',
          noCache: true,
          right:'OwnerData_List',
        },
      },
      {
        path: '/owner-approval/list',
        component: () => import('@/views/product/data/list/index'),
        name: '业主审批',
        meta: {
          title: '业主审批',
          icon: 'dashboard',
          noCache: true,
          right:'OwnerData_List',
        }
      },
      {
        path: '/owner-recommend/list',
        component: () => import('@/views/product/data/list/index'),
        name: '业主推介',
        meta: {
          title: '业主推介',
          icon: 'dashboard',
          noCache: true,
          right:'OwnerData_List',
        }
      },
      {
        path: '/owner-recommend/list',
        component: () => import('@/views/product/data/list/index'),
        name: '业主消费',
        meta: {
          title: '业主消费',
          icon: 'dashboard',
          noCache: true,
          right:'OwnerData_List',
        }
      },
      {
        path: '/owner-recommend/list',
        component: () => import('@/views/product/data/list/index'),
        name: '业主冲值',
        meta: {
          title: '业主冲值',
          icon: 'dashboard',
          noCache: true,
          right:'OwnerData_List',
        }
      },
    ]
  },
  {//商家管理
    path: '',
    component: Layout,
    name: '商家管理',
    meta: {
      title: '商家管理',
      icon: 'dashbord'
    },
    children: [
      {
        path: '/business/list',
        component: () => import('@/views/product/data/list/index'),
        name: '商家列表',
        meta: {
          title: '商家列表',
          icon: 'dashboard',
          noCache: true,
          right:'MerchantData_List',
        },
      },
      {
        path: '/business-commission/list',
        component: () => import('@/views/product/data/list/index'),
        name: '佣金方案',
        meta: {
          title: '佣金方案',
          icon: 'dashboard',
          noCache: true,
          right:'MerchantData_List',
        }
      },
    ]
  },
  {//厂家管理
    path: '',
    component: Layout,
    name: '厂家管理',
    meta: {
      title: '厂家管理',
      icon: 'dashbord'
    },
    children: [
      {
        path: '/business-manufactor/list',
        component: () => import('@/views/product/data/list/index'),
        name: '厂家列表',
        meta: {
          title: '厂家列表',
          icon: 'dashboard',
          noCache: true,
          right:'MerchantFactory_List',
        }
      },
      {
        path: '/business-manufactor/list',
        component: () => import('@/views/product/data/list/index'),
        name: '账号管理',
        meta: {
          title: '账号管理',
          icon: 'dashboard',
          noCache: true,
          right:'MerchantFactory_List',
        }
      },
      {
        path: '/business-manufactor/list',
        component: () => import('@/views/product/data/list/index'),
        name: '地址管理',
        meta: {
          title: '地址管理',
          icon: 'dashboard',
          noCache: true,
          right:'MerchantFactory_List',
        }
      },
    ]
  },
  
  {//峰会管理
    path: '',
    component: Layout,
    name: '峰会管理',
    meta: {
      title: '峰会管理',
      icon: 'dashbord'
    },
    children: [
      {
        path: '/summit/list',
        component: () => import('@/views/product/data/list/index'),
        name: '峰会列表',
        meta: {
          title: '峰会列表',
          icon: 'dashboard',
          noCache: true,
          right:'SummitData_List',
        },
      },
      {
        path: '/summit/list',
        component: () => import('@/views/product/data/list/index'),
        name: '峰会审批',
        meta: {
          title: '峰会审批',
          icon: 'dashboard',
          noCache: true,
          right:'SummitData_List',
        },
      },
      {
        path: '/summit/list',
        component: () => import('@/views/product/data/list/index'),
        name: '参会人员管理',
        meta: {
          title: '参会人员管理',
          icon: 'dashboard',
          noCache: true,
          right:'SummitData_List',
        },
      },
    ]
  },
  {//广告管理
    path: '',
    component: Layout,
    name: '广告管理',
    meta: {
      title: '广告管理',
      icon: 'dashbord'
    },
    children: [
      {
        path: '/summit/list',
        component: () => import('@/views/product/data/list/index'),
        name: '赠品广告',
        meta: {
          title: '赠品广告',
          icon: 'dashboard',
          noCache: true,
          right:'AdvertData_List',
        },
      },
      {
        path: '/summit/list',
        component: () => import('@/views/product/data/list/index'),
        name: '超市广告',
        meta: {
          title: '超市广告',
          icon: 'dashboard',
          noCache: true,
          right:'AdvertData_List',
        },
      },
    ]
  },
  {//系统管理
    path: '',
    component: Layout,
    name: '系统管理',
    iconCls:'el-icon-setting',
    meta: {
      title: '系统管理',
      icon: 'dashbord',
    },
    children: [
      {
        path: '/system/user',
        component: () => import('@/views/user/data/list'),
        name: '用户管理',
        meta: {
          title: '用户管理',
          icon: 'dashboard',
          noCache: true,
          right: 'UserRole_List',
        },
      },
      {
        path: '/user/role',
        component: () => import('@/views/user/role/set'),
        name: '角色设置',
        meta: {
          title: '角色设置',
          icon: 'dashboard',
          noCache: true,
          right: 'UserRole_List',
        },
      },
      {
        path: '/system/department',
        component: () => import('@/views/user/data/list'),
        name: '部门设置',
        meta: {
          title: '部门设置',
          icon: 'dashboard',
          noCache: true,
          right: 'UserRole_List',
        },
      },
      {
        path: '/system/business',
        component: () => import('@/views/user/data/list'),
        name: '业务设置',
        meta: {
          title: '业务设置',
          icon: 'dashboard',
          noCache: true,
          right: 'UserRole_List',
        },
      },
      {
        path: '/system/region',
        component: () => import('@/views/user/data/list'),
        name: '地区设置',
        meta: {
          title: '地区设置',
          icon: 'dashboard',
          noCache: true,
          right: 'UserRole_List',
        },
      },
      
      {
        path: '/system/dataitem',
        component: () => import('@/views/user/data/list'),
        name: '数据项设置',
        meta: {
          title: '数据项设置',
          icon: 'dashboard',
          noCache: true,
          right: 'UserRole_List',
        },
      },
      {
        path: '/system/parameter',
        component: () => import('@/views/user/data/list'),
        name: '系统参数',
        meta: {
          title: '系统参数',
          icon: 'dashboard',
          noCache: true,
          right: 'UserRole_List',
        },
      },
    ]
  },
  
]
